home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Film.WP (PL) info by îwistak & picture by Goster
-
- (***************************************************
- * Movie information & picture importation *
- * script for http://film.wp.pl *
- * (c) 2004 îwistak *
- * (Picture by Goster) *
- * *
- * partialy based on filmweb script *
- * by Piotr Kardasz, Adma's *
- * *
- * For use with Ant Movie Catalog 3.4.3 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program FilmWP;
- var
- MovieName, adres: string;
- Link, id: string;
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure DecodeHTML(var Value: String);
- var
- FullValue, CharCode: String;
- Counter: Integer;
- begin
- if Value <> '' then begin
- FullValue := '';
- Counter := 1;
- repeat
- if StrGet(Value, Counter) <> '&' then
- begin
- CharCode := copy(Value, Counter, 1);
- case CharCode of
- '▒': CharCode := '╣';
- '╢': CharCode := '£';
- 'í': CharCode := 'Ñ';
- '╝': CharCode := 'ƒ';
- 'ª': CharCode := 'î';
- '¼': CharCode := 'Å';
- end;
- FullValue := FullValue + CharCode;
- Counter := Counter + 1;
- end
- else
- begin
- CharCode := copy(Value, Counter, 7);
- case CharCode of
- 'ą': FullValue := FullValue + '╣';
- 'ć': FullValue := FullValue + 'µ';
- 'ę': FullValue := FullValue + 'Ω';
- 'ł': FullValue := FullValue + '│';
- 'ń': FullValue := FullValue + '±';
- 'ó': FullValue := FullValue + '≤';
- 'ś': FullValue := FullValue + '£';
- 'ź': FullValue := FullValue + 'ƒ';
- 'ż': FullValue := FullValue + '┐';
- 'Ą': FullValue := FullValue + 'Ñ';
- 'Ć': FullValue := FullValue + '╞';
- 'Ę': FullValue := FullValue + '╩';
- 'Ł': FullValue := FullValue + 'ú';
- 'Ń': FullValue := FullValue + '╤';
- 'Ó': FullValue := FullValue + '╙';
- 'Ś': FullValue := FullValue + 'î';
- 'Ź': FullValue := FullValue + 'Å';
- 'Ż': FullValue := FullValue + '»';
- 'Š': FullValue := FullValue + ' ';
- 'š': FullValue := FullValue + 'í';
- 'Ţ': FullValue := FullValue + 'í';
- 'ţ': FullValue := FullValue + 'ú';
- 'Ť': FullValue := FullValue + 'ñ';
- 'ť': FullValue := FullValue + 'Ñ';
- 'Ŧ': FullValue := FullValue + 'î';
- 'ŧ': FullValue := FullValue + 'º';
- 'Ũ': FullValue := FullValue + '¿';
- 'ũ': FullValue := FullValue + '⌐';
- 'Ű': FullValue := FullValue + '¬';
- 'ű': FullValue := FullValue + '½';
- 'Ų': FullValue := FullValue + '¼';
- 'ų': FullValue := FullValue + '¡';
- 'Ŵ': FullValue := FullValue + '«';
- 'ŵ': FullValue := FullValue + '»';
- 'Ŷ': FullValue := FullValue + '░';
- 'ŷ': FullValue := FullValue + '▒';
- 'Ÿ': FullValue := FullValue + '▓';
- 'ƀ': FullValue := FullValue + '┤';
- 'Ɓ': FullValue := FullValue + '╡';
- 'Ƃ': FullValue := FullValue + '╢';
- 'ƃ': FullValue := FullValue + '╖';
- 'Ƅ': FullValue := FullValue + '╕';
- 'ƅ': FullValue := FullValue + '╣';
- 'Ɔ': FullValue := FullValue + '║';
- 'Ƈ': FullValue := FullValue + '╗';
- 'ƈ': FullValue := FullValue + '╝';
- 'Ɖ': FullValue := FullValue + '╜';
- 'Ɛ': FullValue := FullValue + '╛';
- 'Ƒ': FullValue := FullValue + '┐';
- 'ƒ': FullValue := FullValue + '└';
- 'Ɠ': FullValue := FullValue + '┴';
- 'Ɣ': FullValue := FullValue + '┬';
- 'ƕ': FullValue := FullValue + '├';
- 'Ɩ': FullValue := FullValue + '─';
- 'Ɨ': FullValue := FullValue + '┼';
- 'Ƙ': FullValue := FullValue + '╞';
- 'ƙ': FullValue := FullValue + '╟';
- 'Ȁ': FullValue := FullValue + '╚';
- 'ȁ': FullValue := FullValue + '╔';
- 'Ȃ': FullValue := FullValue + '╩';
- 'ȃ': FullValue := FullValue + '╦';
- 'Ȅ': FullValue := FullValue + '╠';
- 'ȅ': FullValue := FullValue + '═';
- 'Ȇ': FullValue := FullValue + '╬';
- 'ȇ': FullValue := FullValue + '╧';
- 'Ȉ': FullValue := FullValue + '╨';
- 'ȉ': FullValue := FullValue + '╤';
- 'Ȑ': FullValue := FullValue + '╥';
- 'ȑ': FullValue := FullValue + '╙';
- 'Ȓ': FullValue := FullValue + '╘';
- 'ȓ': FullValue := FullValue + '╒';
- 'Ȕ': FullValue := FullValue + '╓';
- 'ȕ': FullValue := FullValue + '╫';
- 'Ȗ': FullValue := FullValue + '╪';
- 'ȗ': FullValue := FullValue + '┘';
- 'Ș': FullValue := FullValue + '┌';
- 'ș': FullValue := FullValue + '█';
- 'Ƞ': FullValue := FullValue + '▄';
- 'ȡ': FullValue := FullValue + '▌';
- 'Ȣ': FullValue := FullValue + '▐';
- 'ȣ': FullValue := FullValue + '▀';
- 'Ȥ': FullValue := FullValue + 'α';
- 'ȥ': FullValue := FullValue + 'ß';
- 'Ȧ': FullValue := FullValue + 'Γ';
- 'ȧ': FullValue := FullValue + 'π';
- 'Ȩ': FullValue := FullValue + 'Σ';
- 'ȩ': FullValue := FullValue + 'σ';
- 'Ȱ': FullValue := FullValue + 'µ';
- 'ȱ': FullValue := FullValue + 'τ';
- 'Ȳ': FullValue := FullValue + 'Φ';
- 'ȳ': FullValue := FullValue + 'Θ';
- 'ȴ': FullValue := FullValue + 'Ω';
- 'ȵ': FullValue := FullValue + 'δ';
- 'ȶ': FullValue := FullValue + '∞';
- 'ȷ': FullValue := FullValue + 'φ';
- 'ȸ': FullValue := FullValue + 'ε';
- 'ȹ': FullValue := FullValue + '∩';
- 'ɀ': FullValue := FullValue + '≡';
- 'Ɂ': FullValue := FullValue + '±';
- 'ɂ': FullValue := FullValue + '≥';
- 'Ƀ': FullValue := FullValue + '≤';
- 'Ʉ': FullValue := FullValue + '⌠';
- 'Ʌ': FullValue := FullValue + '⌡';
- 'Ɇ': FullValue := FullValue + '÷';
- 'ɇ': FullValue := FullValue + '≈';
- 'Ɉ': FullValue := FullValue + '°';
- 'ɉ': FullValue := FullValue + '∙';
- 'ɐ': FullValue := FullValue + '·';
- 'ɑ': FullValue := FullValue + '√';
- 'ɒ': FullValue := FullValue + 'ⁿ';
- 'ɓ': FullValue := FullValue + '²';
- 'ɔ': FullValue := FullValue + '■';
- 'ɕ': FullValue := FullValue + ' ';
- '%DF;': FullValue := FullValue + '▀';
- '4': FullValue := FullValue + '"';
- '–': FullValue := FullValue + '-';
- '‘': FullValue := FullValue + '"';
- '’': FullValue := FullValue + '"';
- '“': FullValue := FullValue + '"';
- '”': FullValue := FullValue + '"';
- '„': FullValue := FullValue + '"';
- else
- FullValue := FullValue + CharCode;
- end;
- Counter := Counter + 7;
- end;
- until Counter > Length(Value);
- HTMLDecode(FullValue);
- Value := FullValue;
- end
- end;
-
-
- function extractLineText(Line: string; startToken: string; endToken: string): string;
- var
- StartPos: Integer;
- token: string;
- begin
- StartPos := pos(startToken, Line) + Length(startToken);
- Line := copy(Line, StartPos, Length(Line) - StartPos +1);
- Line := copy(Line, 1, Pos(endToken, Line)-1);
- HTMLRemoveTags(Line);
- DecodeHTML(Line);
- extractLineText := Trim(Line);
- end;
-
- function extractText(Page: TStringList; startToken: string; endToken: string; startPos: Integer): string;
- var
- Line: String;
- begin
- Line := copy(Page.Text, startPos, Length(Page.Text)-startPos);
- StartPos := pos(startToken, Line);
- if (StartPos > 0) then
- begin
- StartPos := pos(startToken, Line) + Length(startToken);
- //aby zepewniµ obs│ugΩ przypadku, gdy endToken wystΩpuje tak┐e przed startToken
- Line := copy(Line, StartPos, Length(Page.Text) - StartPos +1);
- Line := copy(Line, 1, Pos(endToken, Line)-1);
- HTMLRemoveTags(Line);
- DecodeHTML(Line);
- Line := Trim(Line);
- Line := StringReplace(Line, #13#10, '');
- end
- else
- Line := '';
-
- extractText := Line;
- end;
-
- function ExtractMovieAddress(Line: string): String ;
- var
- MovieAddress: string;
- StartPos: Integer;
- begin
- StartPos := Pos('<a href=', Line);
- if (StartPos > 0) then
- begin
- MovieAddress := copy(Line, StartPos, Length(Line)-StartPos);
- MovieAddress := copy(MovieAddress, 10, Pos('">', MovieAddress)-10);
- end;
- extractMovieAddress := MovieAddress;
- end;
-
- procedure AddMoviesTitles(Page: TStringList);
- var
- LineNr: Integer;
- Line: string;
- MovieTitle, MovieAddress: string;
- StartPos: Integer;
- begin
- //NajczΩ£ciej szukane
- LineNr := FindLine('szukane:', Page, 0);
- if LineNr > -1 then
- begin
- PickTreeAdd('NajczΩ£ciej szukane:', '');
- MovieTitle := extractLineText(Page.GetString(LineNr+16), '<i>', '</i>');
- if (MovieTitle<>'') then
- MovieTitle := ' (' + MovieTitle + ')';
- MovieTitle := extractLineText(Page.GetString(LineNr+15), '<b>', '</a>')+MovieTitle;
-
- Line := Page.GetString(LineNr+15);
- MovieAddress := extractMovieAddress(Line);
- PickTreeAdd(MovieTitle, MovieAddress);
-
- //Znalezionych
- LineNr := FindLine('Znalezionych:', Page, LineNr);
- Line := Page.GetString(LineNr);
- //Sprawdzamy ile WP znalaz│o pozycji
- StartPos := pos('<b>', Line)+3;
- Line := copy(Line, StartPos, pos('</b>', Line)-StartPos);
- if (StrToInt(Line, 0)>1) then
- begin
- PickTreeAdd('Znalezione ('+Line+'):', '');
- LineNr := LineNr+6;
- repeat
- Line := Page.GetString(LineNr);
- if (pos('span class', Line)>0) then
- begin
- MovieTitle := extractLineText(Page.GetString(LineNr+1), '<i>', '</i>');
- if (MovieTitle<>'') then
- MovieTitle := ' (' + MovieTitle + ')';
- MovieTitle := extractLineText(Page.GetString(LineNr), ' ', '</a>')+MovieTitle;
- MovieAddress := ExtractMovieAddress(Line);
- PickTreeAdd(MovieTitle, MovieAddress);
- end
- else if (pos('znalezione pozycje', Line)>0) then
- begin
- MovieAddress := ExtractMovieAddress(Line);
- PickTreeAdd('Poka┐ wszystkie pozycje...' , MovieAddress);
- end;
- LineNr := LineNr+1;
- until Pos('</table>', Line) > 0;
- end;
- end;
- end;
-
- procedure AnalyzePage(Address: string; PostQuery: string);
- var
- Page: TStringList;
-
- begin
- adres := address;
- Page := TStringList.Create;
- if (PostQuery <> '') then
- Page.Text := PostPage(Address, PostQuery)
- else
- Page.Text := GetPage(Address);
- Link := Address;
- if pos('Podyskutuj na Forum', Page.Text) > 0 then
- AnalyzeMoviePage(Page)
- else if pos('Znalezionych:', Page.Text) > 0 then
- begin
- PickTreeClear;
- AddMoviesTitles(Page);
- if PickTreeExec(Address) then
- AnalyzePage(Address, '');
- end
- else
- begin
- DecodeHTML(MovieName);
- ShowMessage('Nie znaleziono ┐adnego filmu spe│niaj╣cego kryteria: "'+MovieName+'".');
- end
-
- Page.Free;
- end;
-
- procedure AnalyzeMoviePage(Page: TStringList);
- var
- Line, Obsada, OrgLine, linia, tytul: string;
- LineNr, licznik, pozycja, pozycja2: Integer;
- StartPos, endPos: Integer;
- stronka: TStringList;
-
- begin
- // Tytu│ polski & Rok produkcji
- Line := extractText(Page, '<b class="ti">', '</b>', 0);
- //czasami wp dodaje rok produkcji do lini z tytu│em
- StartPos := Pos('(', Line);
- if (StartPos > 0) then
- begin
- SetField(fieldYear, Copy(Line, StartPos+1, 4));
- Line := Copy(Line, 0, StartPos-1);
- end
- setField(fieldTranslatedTitle, Line);
-
- // Tytu│ oryginalny
- Line := extractText(Page, '<i class="ti" id="gr">', '</i>', 0);
- //czasami wp w linii, gdzie jest polski tytu│ umieszcza angielski, polskiego nie za│╣czaj╣c wog≤le...
- if ((Pos('<i class="ti" id="gr">', Page.Text) > Pos('Tw≤rcy:', Page.Text)) or (Line = '')) then
- begin
- Line := getField(fieldTranslatedTitle);
- setField(fieldTranslatedTitle, '');
- end
- setField(fieldOriginalTitle, Line);
-
- // Kategoria
- setField(fieldCategory, extractText(Page, '<b>Gatunek:</b>', '<br>', 0));
-
- // Kraj
- setField(fieldCountry, extractText(Page, '<b>Kraj:</b>', '<br>', 0));
-
- // Czas trwania
- setField(fieldLength, extractText(Page, '<b>Czas trwania:</b>', 'min', 0));
-
- // Rok produkcji
- // Line := extractText(Page, '<b>Premiera kinowa:</b>', '<br>', 0);
- // Line := copy(Line, 1, 4);
- // SetField(fieldYear, Line);
-
- // Ocena
- Line := extractText(Page, 'Ocena internaut≤w:', '</b>', 0);
- if (Line <> '') then
- SetField(fieldRating, IntToStr(Round(StrToFloat(Line))));
-
- // Producent
- //brak
-
- // Re┐yseria
- SetField(fieldDirector, extractText(Page, '<b>Re┐yseria:</b>', '<br>', 0));
-
- // Obsada
- LineNr := FindLine('<b>Obsada:</b>', Page, 0)+1;
- if (LineNr>0) then
- begin
- Obsada := '';
- Line := Page.GetString(LineNr);
- while (Pos('<div align="right">', Line) = 0) do
- begin
- if (Obsada<>'') then
- Obsada := Obsada + ', ';
- HTMLRemoveTags(Line);
- DecodeHTML(Line);
- if (Pos('..... ', Line) > 0) then
- begin
- Line := StringReplace(Line, '..... ', '(jako ');
- Line := Line + ')';
- end;
- Obsada := Obsada + Line;
- LineNr := LineNr+1;
- Line := Page.GetString(LineNr);
- end;
- SetField(fieldActors, Obsada);
- end;
-
- // Czas trwania
- //brak
-
- // Opis filmu
- StartPos := Pos('<b class="ti" id="or">Opis:</b>', Page.Text);
- if (StartPos > 0) then
- SetField(fieldDescription, extractText(Page, '<span id="mi">', '</span>', StartPos));
-
- //Komentarze
- StartPos := Pos('<b class="ti" id="or">Recenzje:', Page.Text);
- //czasami zamiast 'Recenzje' jest 'Opinie'
- if (StartPos = 0) then
- StartPos := Pos('<b class="ti" id="or">Opinie:', Page.Text);
- // if (StartPos > 0) then
- // SetField(fieldComments, extractText(Page, '<span id="mi">', '</span>', StartPos));
-
- //URL
- setField(fieldURL, Link);
-
- //Foto
- //pobranie strony z galeri╣
- stronka := TStringList.Create;
- startPos := pos('id=', adres);
- endPos := pos('&h=', adres);
- id := copy(adres, startPos + 3, endPos - startPos - 3);
- link := 'http://film.wp.pl/film_foto.html?id=' + id + '&m=plakat';
- stronka.Text := GetPage(link);
- PickTreeClear;
- PickTreeAdd('Wybierz ZdjΩcie','');
- licznik := 0;
- pozycja := FindLine('<img src="http://film.wp.pl/f/foto/small/', stronka, 0);
- pozycja2 := FindLine('galeria: ', stronka, pozycja + 1);
- repeat
- begin
- linia := stronka.GetString(pozycja);
- startPos := pos('<img src="http://film.wp.pl/f/foto/small/', linia);
- if (startPos <> 0) then
- begin
- delete(linia, 1, startPos + 9);
- endPos := pos('.gif"', linia);
- tytul := copy(linia, 1, endPos + 3);
- licznik := licznik + 1;
- tytul := StringReplace(tytul, 'small/', '');
- tytul := StringReplace(tytul, 'gif', 'jpg');
- adres := tytul;
- startPos := pos('alt="', linia);
- delete(linia, 1, startPos + 4);
- endPos := pos('">', linia);
- tytul := copy(linia, 1, endPos - 1);
- PickTreeAdd(IntToStr(licznik) + tytul, adres);
- end;
- pozycja := pozycja + 1;
- end;
- until (pozycja >= pozycja2);
- if licznik > 1 then
- begin
- if PickTreeExec(adres) then
- GetPicture(adres, False);
- end;
- if licznik = 1 then
- GetPicture(adres, False);
- stronka.Free;
-
-
- DisplayResults;
- end;
-
- begin
- if CheckVersion(3,4,3) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- if Input('FilmWP Import', 'Podaj tytu│ filmu:', MovieName) then
- begin
- // Zamiana na ISO-8859-2
- MovieName:=StringReplace(MovieName, '╣', chr(177));
- MovieName:=StringReplace(MovieName, 'µ', chr(230));
- MovieName:=StringReplace(MovieName, 'Ω', chr(234));
- MovieName:=StringReplace(MovieName, '│', chr(179));
- MovieName:=StringReplace(MovieName, '±', chr(241));
- MovieName:=StringReplace(MovieName, '≤', chr(243));
- MovieName:=StringReplace(MovieName, '£', chr(182));
- MovieName:=StringReplace(MovieName, 'ƒ', chr(188));
- MovieName:=StringReplace(MovieName, '┐', chr(191));
- MovieName:=StringReplace(MovieName, 'Ñ', chr(161));
- MovieName:=StringReplace(MovieName, '╞', chr(198));
- MovieName:=StringReplace(MovieName, '╩', chr(202));
- MovieName:=StringReplace(MovieName, 'ú', chr(163));
- MovieName:=StringReplace(MovieName, '╤', chr(209));
- MovieName:=StringReplace(MovieName, '╙', chr(211));
- MovieName:=StringReplace(MovieName, 'î', chr(166));
- MovieName:=StringReplace(MovieName, 'Å', chr(172));
- MovieName:=StringReplace(MovieName, '»', chr(175));
- AnalyzePage('http://film.wp.pl/p/szukaj.html', 'fromBox=1&szukaj='+MovieName+'&lista=a0');
- end;
- end
- else
- ShowMessage('Skrypt wymaga programu Ant Movie Catalog w wersji 3.4.3 lub nowszej');
- end.
-
-
-